package personal

import (
	"context"
	"grpc-common/api/user/personal"
	personalLogic "user/internal/logic/personal"

	"github.com/gogf/gf/contrib/rpc/grpcx/v2"
)

type PersonalController struct {
	personal.UnimplementedPersonalServer
}

func RegisterPersonalServer(s *grpcx.GrpcServer) {
	personal.RegisterPersonalServer(s.Server, &PersonalController{})
}

func (*PersonalController) GetUserList(ctx context.Context, req *personal.PageInfo) (res *personal.UserListResponse, err error) {
	logic := personalLogic.NewPersonalLogic()
	return logic.GetUserList(ctx, req)
}

func (*PersonalController) GetUserByMobile(ctx context.Context, req *personal.MobileRequest) (res *personal.UserInfoResponse, err error) {
	logic := personalLogic.NewPersonalLogic()
	return logic.GetUserByMobile(ctx, req)
	//return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

func (*PersonalController) GetUserById(ctx context.Context, req *personal.IdRequest) (res *personal.UserInfoResponse, err error) {
	logic := personalLogic.NewPersonalLogic()
	return logic.GetUserById(ctx, req)
	//return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

func (*PersonalController) CreateUser(ctx context.Context, req *personal.CreateUserInfo) (res *personal.UserInfoResponse, err error) {
	logic := personalLogic.NewPersonalLogic()
	return logic.CreateUser(ctx, req)
	//return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

func (*PersonalController) UpdateUser(ctx context.Context, req *personal.UpdateUserInfo) (res *personal.UpdateUserRes, err error) {
	logic := personalLogic.NewPersonalLogic()
	return logic.UpdateUser(ctx, req)
	//return nil, gerror.NewCode(gcode.CodeNotImplemented)
}

func (*PersonalController) CheckPassWord(ctx context.Context, req *personal.PasswordCheckInfo) (res *personal.CheckResponse, err error) {
	logic := personalLogic.NewPersonalLogic()
	return logic.CheckPassWord(ctx, req)
	//return nil, gerror.NewCode(gcode.CodeNotImplemented)
}
